<template>
	<view class="Mine">
		 <u-navbar :titleStyle="titleStyle" title=" " bg-color="transparent" left-icon=" "></u-navbar>
		 <view class="topBg"></view>
		 <view class="topbox1">
			 <view class="topbox">
				 <view class="left">
					<u-image :src="userInfo ? userInfo.avatar : '/static/no-login-avator.png'" width="130rpx" height="130rpx" radius="130rpx" customStyle="border: 1px solid yellow;"/>
					<view class="userbox">
						<view class="userinfo" :style="!userInfo ? 'flex-direction: column;align-items: start;' : ''">
							<view v-if="!userInfo" class="app_title">{{ appName }}</view>
							<view v-if="userInfo">{{ userInfo.username }}</view>
							<view v-else class="showLogin" @click="$goUrl('/pages/login/login/login','to')">
								点击登录 查看您的会员等级
							</view>
							<view v-if="userInfo.card && showCard" class="taginfo" :class="'card_type' + userInfo.card.card_type">
								<u-image src="/static/mine/icon1.png" width="29rpx" height="24rpx"/>
								<text>{{ userInfo.card.card_type == 1 ? '黄金版会员' : '豪华版会员'}}</text>
							</view>
						</view>
						<view v-if="userInfo" class="logininfo">登录号码：{{ userInfo.nickname }}</view>
					</view>
				 </view>
				 <view class="right">
					 <!-- <u-image src="/static/mine/set.png" width="37rpx" height="39rpx"/> -->
				 </view>
			 </view>
			 <view class="walletbox" @click="$goUrl('/pages/mine/wallet/wallet','to')">
				 <view class="left">
					 <u-image src="/static/mine/wallet.png" width="38rpx" height="35rpx"/>
					 <text>我的钱包</text>
				 </view>
				 <view v-if="userInfo" class="flex_box">￥ {{ userInfo.money || 0}} <u-icon name="arrow-right" color="#ffff"></u-icon></view>
				 <view v-else class="flex_box" @click="$goUrl('/pages/login/login/login','to')">登录可查看您的余额 <u-icon name="arrow-right" color="#ffff"></u-icon></view>
			 </view>
			 <view class="item-box">
				 <view class="title">权益卡管理</view>
				 <view class="item">
					 <view class="images" @click="$goUrl('/pages/mine/card/card','to')">
						 <u-image src="/static/mine/icon11.png" width="68rpx" height="68rpx"/>
						 <view class="text">我的卡包</view>
					 </view>
					 <view class="images" @click="goOrder(1)">
						 <u-image src="/static/mine/icon12.png" width="68rpx" height="68rpx"/>
						 <view class="text">预约订单</view>
					 </view>
					 <view class="images" @click="goActive">
						 <u-image src="/static/mine/icon13.png" width="68rpx" height="68rpx"/>
						 <view class="text">会员激活</view>
					 </view>
					 <view class="images" @click="$goUrl('pages/mine/card/buy','to')">
						 <u-image src="/static/mine/icon14.png" width="68rpx" height="68rpx"/>
						 <view class="text">会员购买</view>
					 </view>
				 </view>
			 </view>
			 <view class="item-box">
				 <view class="title">旅游人管理</view>
				 <view class="item">
					 <view class="images" @click="$goUrl('/pages/mine/travel/travel','to')">
						 <u-image src="/static/mine/icon21.png" width="68rpx" height="68rpx"/>
						 <view class="text">游人信息</view>
					 </view>
					 <view class="images" @click="goOrder(2)">
						 <u-image src="/static/mine/icon22.png" width="68rpx" height="68rpx"/>
						 <view class="text">我的订单</view>
					 </view>
					 <view class="images" @click="goOrder(3)">
						 <u-image src="/static/mine/icon23.png" width="68rpx" height="68rpx"/>
						 <view class="text">游玩记录</view>
					 </view>
					 <view class="images">
						<button open-type="contact" class="u-reset-button button">
							  <u-image src="/static/mine/icon24.png" width="68rpx" height="68rpx"/>
							  <view class="text">客服中心</view>
						 </button>
					 </view>
				 </view>
			 </view>
			 <view class="item-box">
				 <view class="title">代理商管理</view>
				 <view class="item last">
					 <view class="images" @click="goAgent">
						 <u-image src="/static/mine/icon31.png" width="68rpx" height="68rpx"/>
						 <view class="text">代理中心</view>
					 </view>
					 <view class="images" @click="$goUrl('pages/home/index/service', 'to')">
						 <u-image src="/static/mine/icon32.png" width="68rpx" height="68rpx"/>
						 <view class="text">服务商</view>
					 </view>
				 </view>
			 </view>
		 </view>
	</view>
</template>

<script>
	import {
		getInfo,
		circuitList,
		getSetInfo,
		checkVip
	} from '@/common/http.api.js';
	let that;
	export default {
		data() {
			return {
				titleStyle: {
					color: '#BBF4E9',
				},
				showCard: false,
				appName: '',
			};
		},
		onLoad() {
			that = this;
			that.getSetInfo();
			that.appName = uni.getSystemInfoSync().appName;
		},
		onShow() {
			if (that.loginInfo) that.getInfo();
		},
		methods: {
			getSetInfo() {
				getSetInfo()
					.then(res => {
						if (res.code == 1) {
							that.phoneNum = res.data.ty_mobile;
						} else {
							uni.$u.toast(res.msg);
						}
					})
					.catch(err => {});
			},
			getInfo() {
				getInfo()
					.then(res => {
						if (res.code == 1) {
							uni.$u.vuex('userInfo', res.data);
							if (['1', '2'].includes(res.data.card.card_type)) {
								that.showCard = true
							}
						} else {
							uni.$u.toast(res.msg);
						}
					})
					.catch(err => {});
			},
			goActive() {
				checkVip().then(res => {
					if (res.data == 1) {
						that.$goUrl('/pages/mine/card/card', 'to')
					} else {
						that.$goUrl('/pages/mine/card/active', 'to')
					}
				}).catch(err => {
					uni.$u.toast(err.msg);
				});
			},
			goOrder(current) {
				uni.setStorageSync('currentOrderType', current - 1);
				// uni.$emit('currentEvent', {'data': current - 1});
				uni.switchTab({
					url: '/pages/travel/index/index'
				});
			},
			goAgent() {
				if (that.agentInfo) {
					that.$goUrl('/pages/mine/agent/agent', 'to')
				} else {
					that.$goUrl('/pages/mine/agent/login', 'to')
				}
			},
		}
	};
</script>

<style lang="scss" scoped>
	.Mine {
		min-height: calc(100vh + 50px);
		background-color: #F5F5F5;
		.topBg {
			width: 750rpx;
			height: 595rpx;
			background: linear-gradient(135deg, #BBF4E9, #EDFFFC, #EDFFFC, #EDFFFC, #CCF6F5);
		}
		.topbox1 {
			position: absolute;
			top: 1rpx;
			.mine_top {
				display: flex;
				justify-content: space-between;
				margin-top: 200rpx;
			}
		}
		.topbox {
			height: 130rpx;
			margin-top: 172rpx;
			display: flex;
			align-items: center;
			padding: 0 30rpx;
			width: 750rpx;
			.left {
				flex: 1;
				display: flex;
				align-items: center;
				margin-left: 10rpx;
				.userbox {
					margin-left: 10rpx;
					.userinfo {
						.app_title {
							font-family: SourceHanSansCN, SourceHanSansCN;
							font-weight: bold;
							font-size: 32rpx;
							color: #333333;
							text-align: left;
							font-style: normal;
							text-transform: none;
						}
						.showLogin {
							font-family: SourceHanSansCN, SourceHanSansCN;
							font-weight: 400;
							font-size: 26rpx;
							color: #999999;
							text-align: left;
							font-style: normal;
							text-transform: none;
						}
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #333333;
						line-height: 30rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
						gap: 10rpx;
						.taginfo {
							display: flex;
							font-family: Source Han Sans CN;
							font-weight: 400;
							font-size: 24rpx;
							color: #FFFFFF;
							line-height: 30rpx;
							border-radius: 10rpx;
							padding: 8rpx 10rpx;	
							border-radius: 25rpx;
							align-items: center;
						}
						.card_type2 {
							background: linear-gradient(135deg, #CAAF64, #E6D9A0);
						}
						.card_type1 {
							background: #4FC3AD;
						}
					}
					.logininfo {
						height: 24rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 26rpx;
						color: #333333;
					}
				}
			}
			.right {
				width: 40rpx;
			}
		}
		.walletbox {
			display: flex;
			justify-content: space-between;
			align-items: center;
			background: #49ccc4;
			border-top-left-radius: 30rpx;
			border-top-right-radius: 30rpx;
			color: #fff;
			padding: 20rpx 30rpx;
			margin: 30rpx;
			.left {
				display: flex;
				gap: 10rpx;
			}
		}
		.item-box {
			width: 690rpx;
			height: 267rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			margin: 30rpx auto 0;
			padding: 30rpx;
			.title {
				height: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 34rpx;
				color: #333333;
				line-height: 38rpx;
				margin-bottom: 30rpx;
			}
			.item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 50rpx;
				.images {
					display: flex;
					flex-direction: column;
					align-items: center;
					gap: 30rpx;
					.button {
						display: flex;
						flex-direction: column;
						align-items: center;
						gap: 30rpx;
					}
					.text {
						width: 103rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 26rpx;
						color: #333333;
						line-height: 38rpx;
						text-align: center;
					}
				}
			}
			.last {
				justify-content: start;
				gap: 69rpx;
			}
		}
	}
</style>